package com.aa.activity;



import java.util.ArrayList;
import java.util.HashMap;

import com.aa.R;

import android.R.integer;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class AbountAA extends Activity {

	private ListView mListView;
	private int[] mText = {R.string.common_problem,R.string.brand_commitment,R.string.office_release,R.string.abount_yueteng
			,R.string.link_us,R.string.diy};
			int[] mImage = {R.drawable.abount_aa_item_select_img};
	private Button mbtnTitleBack;
	private TextView mtvTitleCenter;
	private ScrollView mScrollView;
	private ImageView mImageView;
	private TextView mtvTitle;
	@Override
	protected void onCreate(Bundle savedInstanceState) {		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.about);
		initView();
		createListView();
	}
	
	@SuppressLint("NewApi")
	private void initView(){
		mListView = (ListView)findViewById(R.id.abount_aa_list);
		mListView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				mListView.setVisibility(View.GONE);
				
				switch (arg2) {
				case 0:
					mtvTitle.setText(mText[0]);
					break;
				case 1:
					mtvTitle.setText(mText[1]);
					break;
				case 2:
					mtvTitle.setText(mText[2]);
					break;
				case 3:
					mtvTitle.setText(mText[3]);
					break;
				case 4:
					mtvTitle.setText(mText[4]);
					break;
				case 5:
					mtvTitle.setText(mText[5]);
					break;
			
				}
				
				
			}
		});
		mbtnTitleBack = (Button)findViewById(R.id.btn_title_back);
		mbtnTitleBack.setOnClickListener(new OnClickListener() {			
			@Override
			public void onClick(View v) {
				finish();				
			}
		});
		mtvTitleCenter = (TextView)findViewById(R.id.tv_title_center);
		mtvTitleCenter.setText(R.string.abount_aa);
		mScrollView = (ScrollView)findViewById(R.id.sv_abount_aa);
		mImageView = (ImageView)findViewById(R.id.iv_title_img);
		mImageView.setVisibility(View.VISIBLE);
		mImageView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if (mListView.isShown()) {
					mListView.setVisibility(View.GONE);
				}else {
					mListView.setVisibility(View.VISIBLE);
				}												
			}
		});
		mtvTitle = (TextView)findViewById(R.id.tv_abount_aa_title);
		mtvTitle.setText(mText[0]);
	}

	private void createListView(){
		mListView.setAdapter(getMenuAdapter(mText, mImage));
	}
	
	private SimpleAdapter getMenuAdapter(int[] pText, int[] pImage){
	    ArrayList _ArrayList = new ArrayList();
	    for (int i = 0; ; i++){
	    	
	      if (i >= pText.length)
	        return new SimpleAdapter(this, _ArrayList, R.layout.list_item_2, new String[] { "list_title", "list_img" }, new int[] { R.id.list_title, R.id.list_img });
	      HashMap _HashMap = new HashMap();
	      _HashMap.put("list_title", getApplicationContext().getString(pText[i]));
	      _HashMap.put("list_img", Integer.valueOf(pImage[0]));
	      _ArrayList.add(_HashMap);
	    }
	  }
}
